const express = require("express");
const router = express.Router();

const ArticleValidate = require("../validator/article");
const { authenticateToken, authorize } = require("../middleware/auth");

const ResponseHelper = require("../util/response");
const articlectrl = require("../controller/article");
// 创建文章
router.post(
  "/add",
  authenticateToken,
  ArticleValidate.createArticle,
  articlectrl.createArticle
);
// 获取文章列表
router.get("/list", articlectrl.getArticles);

// 获取文章详情
router.get(
  "/detail/:id",
  ArticleValidate.getArticleDetail,
  articlectrl.getArticlesDetail
);

// // 更新文章
router.put(
  "/update/:id",
  authenticateToken,
  ArticleValidate.updateArticle,
  articlectrl.updateArticles
);

// 删除文章
router.delete(
  "/delete/:id",
  authenticateToken,
  ArticleValidate.deleteArticle,
  articlectrl.deleteArticles
);

module.exports = router;
